/******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
* File Name          : hw_config.h
* Author             : MCD Application Team
* Version            : V3.2.1
* Date               : 07/05/2010
* Description        : Hardware Configuration & Setup
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

#ifndef __HW_CONFIG_H
#define __HW_CONFIG_H

#include "stm32f10x.h"


#define BULK_MAX_PACKET_SIZE  0x00000040


typedef enum 
{
	LED0,  //none
	LED1,  //buzzer
	LED2,   // LAMP 
	LED3,   // Rain wiper
	LED4,  // Remove fog
	LED5,  // Fn
	LED6,  // record
	LED7,  // intelligent 
	LED8,  // shift
	LED9   // shutter(after omit)
} Led_TypeDef;


//LED 

#define GPIO_LED1CNTRL_IO		    GPIOC
#define GPIO_LED1_PIN		        GPIO_Pin_6   //OUT2

#define GPIO_LED2CNTRL_IO		    GPIOD
#define GPIO_LED2_PIN		        GPIO_Pin_2   //OUT2

#define  GPIO_LED3CNTRL_IO		    GPIOD
#define  GPIO_LED3_PIN		        GPIO_Pin_15// OUT3


#define  GPIO_LED4CNTRL_IO		    GPIOE
#define  GPIO_LED4_PIN		        GPIO_Pin_13// re_fog

#define  GPIO_LED5CNTRL_IO		    GPIOD
#define  GPIO_LED5_PIN		        GPIO_Pin_5// Fn

#define  GPIO_LED6CNTRL_IO		    GPIOD
#define  GPIO_LED6_PIN		        GPIO_Pin_4// record

#define  GPIO_LED7CNTRL_IO		    GPIOD
#define  GPIO_LED7_PIN		        GPIO_Pin_6//Intelligent_Led

#define  GPIO_LED8CNTRL_IO		    GPIOD
#define  GPIO_LED8_PIN		        GPIO_Pin_3//Shift

#define  GPIO_LED9CNTRL_IO		    GPIOA
#define  GPIO_LED9_PIN		        GPIO_Pin_9//Shutter_Led



#define Buzzer_ON()  GPIO_SetBits(GPIOC,GPIO_Pin_6);
#define Buzzer_OFF()  GPIO_ResetBits(GPIOC,GPIO_Pin_6);

#define LED2_ON()		GPIO_ResetBits(GPIO_LED2CNTRL_IO, GPIO_LED2_PIN)
#define LED2_OFF()		GPIO_SetBits(GPIO_LED2CNTRL_IO,GPIO_LED2_PIN)

#define LED3_ON()		GPIO_ResetBits(GPIO_LED3CNTRL_IO, GPIO_LED3_PIN)
#define LED3_OFF()		GPIO_SetBits(GPIO_LED3CNTRL_IO,GPIO_LED3_PIN)

#define LED4_ON()		GPIO_ResetBits(GPIO_LED4CNTRL_IO, GPIO_LED4_PIN)
#define LED4_OFF()		GPIO_SetBits(GPIO_LED4CNTRL_IO,GPIO_LED4_PIN)

#define LED5_ON()		GPIO_ResetBits(GPIO_LED5CNTRL_IO, GPIO_LED5_PIN)
#define LED5_OFF()		GPIO_SetBits(GPIO_LED5CNTRL_IO,GPIO_LED5_PIN)

#define LED6_ON()		GPIO_ResetBits(GPIO_LED6CNTRL_IO, GPIO_LED6_PIN)
#define LED6_OFF()		GPIO_SetBits(GPIO_LED6CNTRL_IO,GPIO_LED6_PIN)

#define LED7_ON()		GPIO_ResetBits(GPIO_LED7CNTRL_IO, GPIO_LED7_PIN)
#define LED7_OFF()		GPIO_SetBits(GPIO_LED7CNTRL_IO,GPIO_LED7_PIN)

#define LED8_ON()		GPIO_ResetBits(GPIO_LED8CNTRL_IO, GPIO_LED8_PIN)
#define LED8_OFF()		GPIO_SetBits(GPIO_LED8CNTRL_IO,GPIO_LED8_PIN)

#define LED9_ON()		GPIO_ResetBits(GPIO_LED9CNTRL_IO, GPIO_LED9_PIN)
#define LED9_OFF()		GPIO_SetBits(GPIO_LED9CNTRL_IO,GPIO_LED9_PIN)


#define KEY_PRESET2_PRESSED (GPIO_ReadInputDataBit(GPIOB,GPIO_Pin_12)==0)   // preset2(F3)
#define KEY_F1_PRESSED (GPIO_ReadInputDataBit(GPIOD,GPIO_Pin_0)==0)   //F1
#define KEY_PLAYBACK_PRESSED (GPIO_ReadInputDataBit(GPIOE,GPIO_Pin_2)==0)// Require

uint8_t LED_Toggle(Led_TypeDef LEDX);
                      
void Set_System(void);
void Set_USBClock(void);
void Enter_LowPowerMode(void);
void Leave_LowPowerMode(void);
void USB_Interrupts_Config(void);
void Led_Config(void);
void Led_RW_ON(void);
void Led_RW_OFF(void);
void USB_Configured_LED(void);
void USB_NotConfigured_LED(void);
void USB_Cable_Config (FunctionalState NewState);
void Get_SerialNum(void);
void MAL_Config(void);

void USB_Disconnect_Config(void);


#endif  /*__HW_CONFIG_H*/

/******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
